<template>
  <div class="baseMessage">
    <!--    基本信息-->
    <form-message :model="formInfo">
      <!--      就诊时间-->
      <form-message-item v-if="isShow.jzsj">
        <div slot="message">就诊时间：</div>
        <div slot="content">
          <el-date-picker
            v-model="formInfo.jzsj"
            type="daterange"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          />
        </div>
      </form-message-item>
      <!--      出院时间-->
      <form-message-item v-if="isShow.cysj">
        <div slot="message">出院时间：</div>
        <div slot="content">
          <el-date-picker
            v-model="formInfo.cysj"
            type="daterange"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          />
        </div>
      </form-message-item>
      <!--      处方时间-->
      <form-message-item v-if="isShow.cfsj">
        <div slot="message">处方时间：</div>
        <div slot="content">
          <el-date-picker
            v-model="formInfo.cfsj"
            type="daterange"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          />
        </div>
      </form-message-item>

      <!--      <form-message-item v-if="isShow.sj">-->
      <!--        <div v-if="(father === 'prescription')" slot="message">处方时间：</div>-->
      <!--        <div v-if="(father === 'patient')" slot="message">处方时间：</div>-->
      <!--        <div v-if="(father === 'antibacterial')" slot="message">处方时间：</div>-->
      <!--        <div v-if="(father === 'prcInpatientReview' || father === 'PrcElectronicMedicine')" slot="message">出院时间：</div>-->
      <!--        <div v-if="(father === 'dcCenter')" slot="message">数据时间：</div>-->

      <!--      </form-message-item>-->
      <form-message-item v-if="isShow.jzlx">
        <div slot="message">就诊类型：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.jzlx">
            <el-checkbox label="门诊"><span class="fontSize12">门诊</span></el-checkbox>
            <el-checkbox label="急诊"><span class="fontSize12">急诊</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.dpjg" :is-long="true">
        <div slot="message">点评结果：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.dpjg">
            <el-checkbox label="未点评"><span class="fontSize12">未点评</span></el-checkbox>
            <el-checkbox label="点评合理"><span class="fontSize12">点评合理</span></el-checkbox>
            <el-checkbox label="点评不合理"><span class="fontSize12">点评不合理</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <!--就诊科室-->
      <form-message-item v-if="isShow.jzks">
        <div slot="message">就诊科室：</div>
        <div slot="content">
          <el-input v-model="formInfo.jzks" clearable placeholder="请输入就诊科室" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('就诊科室',father,'jzks',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('jzks')"
          >清除
          </el-button>
        </div>
      </form-message-item>
      <!--      当前科室-->
      <form-message-item v-if="isShow.dqks">
        <div slot="message">当前科室：</div>
        <div slot="content">
          <el-input v-model="formInfo.jzks" clearable placeholder="请输入当前科室" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('当前科室',father,'dqks',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('dqks')"
          >清除
          </el-button>
        </div>
      </form-message-item>
      <!--      出院科室-->
      <form-message-item v-if="isShow.cyks">
        <div slot="message">出院科室：</div>
        <div slot="content">
          <el-input v-model="formInfo.cyks" clearable placeholder="请输入出院科室" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('出院科室',father,'cyks',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('cyks')"
          >清除
          </el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.dpr">
        <div slot="message">点评人：</div>
        <div slot="content">
          <el-input v-model="formInfo.dpr" clearable placeholder="请输入点评人" />
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.cfks">
        <div slot="message">处方科室：</div>
        <div slot="content">
          <el-input v-model="formInfo.cfks" clearable placeholder="请输入处方科室" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('处方科室',father,'cfks',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('cfks')"
          >清除
          </el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.zyks">
        <div slot="message">住院科室：</div>
        <div slot="content">
          <el-input v-model="formInfo.zyks" clearable placeholder="请输入室住院科" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('住院科室',father,'cfks',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('cfks')"
          >清除
          </el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.cfys">
        <div slot="message">处方医生：</div>
        <div slot="content">
          <el-input v-model="formInfo.cfys" clearable placeholder="请输入处方医生" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('处方医生',father,'cfys',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('cfys')"
          >清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.kzys">
        <div slot="message">开嘱医生：</div>
        <div slot="content">
          <el-input v-model="formInfo.kzys" clearable placeholder="请输入开嘱医生" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('开嘱医生',father,'kzys',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('kzys')"
          >清除</el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.zgys">
        <div slot="message">主管医生：</div>
        <div slot="content">
          <el-input v-model="formInfo.zgys" clearable placeholder="请输入主管医生" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('主管医生',father,'cfys',true)"
          >选择
          </el-button>
          <el-button
            size="mini"
            type="primary"
            @click="cleanInput('cfys')"
          >清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.ysjb" :is-long="true">
        <div slot="message">医生级别：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.ysjb" class="doctorLevel">
            <el-checkbox label="住院医师"><span
              class="fontSize12"
            >住院医师</span></el-checkbox>
            <el-checkbox label="主治医师"><span
              class="fontSize12"
            >主治医师</span></el-checkbox>
            <el-checkbox label="副主任医师"><span
              class="fontSize12"
            >副主任医师</span></el-checkbox>
            <el-checkbox label="主任医生"><span
              class="fontSize12"
            >主任医生</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.cflx">
        <div slot="message">处方类型：</div>
        <div slot="content">
          <el-radio v-model="formInfo.cflx" label="1"><span
            class="fontSize12"
          >全部处方</span></el-radio>
          <el-radio v-model="formInfo.cflx" label="2"><span
            class="fontSize12"
          >非抗菌药处方</span></el-radio>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.fb">
        <div slot="message">费别：</div>
        <div slot="content">
          <el-input v-model="formInfo.fb" clearable placeholder="请输入费别" />
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.brxm">
        <div slot="message">病人姓名：</div>
        <div slot="content">
          <el-input v-model="formInfo.brxm" clearable placeholder="请输入病人姓名" />
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.xb">
        <div slot="message">性别：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.xb">
            <el-checkbox label="male"><span class="fontSize12">男</span></el-checkbox>
            <el-checkbox
              label="female"
            ><span class="fontSize12">女</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.brnl">
        <div slot="message">病人年龄：</div>
        <div slot="content">
          <el-row>
            <el-col :span="10"><el-input
              v-model="formInfo.brnl.start"
              clearable
            /></el-col>
            <el-col :span="2"><span style="padding-left: 5px">至</span></el-col>
            <el-col :span="10"><el-input
              v-model="formInfo.brnl.end"
              clearable
            /></el-col>
            <el-col :span="2"><span style="padding-left: 5px">岁</span></el-col>
          </el-row>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.cfh">
        <div slot="message">处方号：</div>
        <div slot="content">
          <el-input v-model="formInfo.cfh" clearable placeholder="多个请用英文逗号隔开" />
        </div>
        <div slot="buttons">
          <el-button type="primary" size="mini">导入</el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.mzh">
        <div slot="message">门诊号：</div>
        <div slot="content">
          <el-input v-model="formInfo.mzh" clearable placeholder="多个请用英文逗号隔开" />
        </div>
        <div slot="buttons">
          <el-button type="primary" size="mini">导入</el-button>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.zyh">
        <div slot="message">住院号：</div>
        <div slot="content">
          <el-input v-model="formInfo.zyh" clearable placeholder="多个请用英文逗号隔开" />
        </div>
        <div slot="buttons">
          <el-button type="primary" size="mini">导入</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.zd">
        <div slot="message">诊断：</div>
        <div slot="content">
          <el-input v-model="formInfo.zd" clearable placeholder="请输入" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('诊断',father,'zd',true)"
          >选择</el-button>

          <el-button size="mini" type="primary" @click="cleanInput('zd')">清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.dpjg2" :is-long="true">
        <div slot="message">点评结果：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.dpjg2">
            <el-checkbox label="未点评"><span class="fontSize12">未点评</span></el-checkbox>
            <el-checkbox label="已点评"><span class="fontSize12">已点评</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.wzdcf">
        <div slot="message">无诊断处方：</div>
        <div slot="content">
          <el-checkbox
            v-model="formInfo.wzdcf"
          ><span class="fontSize12">排除</span></el-checkbox>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.brid">
        <div slot="message">病人ID：</div>
        <div slot="content">
          <el-input v-model="formInfo.brid" clearable placeholder="请输入病人ID" />
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.swbr">
        <div slot="message">死亡病人：</div>
        <div slot="content">
          <el-checkbox
            v-model="formInfo.swbr"
          ><span class="fontSize12">排除</span></el-checkbox>
        </div>
      </form-message-item>

    </form-message>
  </div>
</template>

<script>
import FormMessage from './FormMessage'
import FormMessageItem from './FormMessageItem'

export default {
  name: 'BaseMessage',
  components: {
    FormMessage,
    FormMessageItem
  },
  props: {
    isShow: {
      type: Object,
      default: null,
      cysj: false, jzsj: false, cfsj: false,
      cyks: false, jzks: false, cfks: false, zyks: false, dqks: false,
      jzlx: false,
      dpjg: false, dpjg2: false,
      dpr: false, cfys: false, ysjb: false,
      cflx: false, fb: false, brxm: false, xb: false,
      brnl: false, cfh: false, zd: false, wzdcf: false,
      zgys: false, zyh: false, mzh: false, brid: false, swbr: false
    },
    isPassValue: {
      type: Boolean,
      default: false
    },
    isPassValue2: {
      type: Boolean,
      default: false
    },
    isPassValuetoEMedicine: {
      type: Boolean,
      default: false
    },
    father: {
      type: String,
      default: null
    },
    selectedResult: {
      type: String,
      default: null
    }
  },
  data() {
    return {
      // 表单数据
      formInfo: {
        cfsj: '', jzsj: '',
        jzlx: [], jzks: [],
        dpjg: [], dpjg2: [],
        dpr: '', cfks: '', zyks: '', dqks: '', cfys: '', ysjb: [],
        cflx: [], fb: '', brxm: '', xb: [], kzys: '',
        brnl: {
          start: '',
          end: ''
        },
        cfh: '', zd: '', wzdcf: '', zgys: '', zyh: '', mzh: '', brid: '', swbr: ''
      },
      // 对话框数据
      dialogInfo: {
        title: '',
        father: '',
        infoData: '',
        isTransfer: null
      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      }
    }
  },
  watch: {
    isPassValue() {
      if (this.isPassValue === true) {
        this.$emit('acquireInfo', 'baseMessageInfo', this.formInfo)
      }
    },
    isPassValue2() {
      if (this.isPassValue2 === true) {
        this.$emit('acquireInfo2', this.formInfo)
      }
    },
    isPassValuetoEMedicine() {
      if (this.isPassValue2 === true) {
        this.$emit('acquireInfotoEmedicine', this.formInfo)
      }
    },
    selectedResult() {
      if (this.selectedResult === '') {
        console.log(this.selectedResult)
      } else {
        this.formInfo[this.dialogInfo.infoData] = this.selectedResult
        // console.log(this.formInfo)
      }
    }
  },
  methods: {
    chooseDialog(title, father, infoData, isTransfer) {
      this.dialogInfo.title = title
      this.dialogInfo.father = father
      this.dialogInfo.infoData = infoData
      this.dialogInfo.isTransfer = isTransfer
      this.$emit('chooseDialog', this.dialogInfo)
    },
    cleanInput(value) {
      for (const item in this.formInfo) {
        if (item === value) {
          this.$set(this.formInfo, value, '')
          break
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">

  .el-button, .el-input{
    font-size: 12px;
  }
  .baseMessage{
    font-size: 12px !important;
  }
  .fontSize12{
    font-size: 12px !important;
  }
  .el-row{
  margin-bottom: 5px;
}

</style>
